/*
 *  (C) Copyright 2008 Insula T.I. Ltda.
 * 
 *  This file is part of Vulcano.
 *
 *  Vulcano is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Vulcano is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Vulcano.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.openinsula.vulcano.orm.dao.query;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openinsula.vulcano.orm.dao.Dao;
import org.openinsula.vulcano.orm.dao.query.spec.Spec;

/**
 * @author rebola
 * @author yanaga
 * @since 1.0
 * @see Dao
 * @see DaoQueryBuilder
 */
public abstract class DaoQuery<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	protected final Log logger = LogFactory.getLog(getClass());

	protected Class<?> queryClass;

	protected Spec spec;

	protected int limit = 0;

	protected int firstResult = 0;

	protected List<String> orderParameters = new LinkedList<String>();

	protected boolean lock = false;

	public DaoQuery(final Class<?> queryClass) {
		this(queryClass, null);
	}

	public DaoQuery(final Class<?> queryClass, final Spec spec) {
		this.queryClass = queryClass;
		this.spec = spec;
	}

	public abstract <V> V accept(DaoQueryVisitor<V> visitor);

	public Class<?> getQueryClass() {
		return queryClass;
	}

	public Spec getSpec() {
		return spec;
	}

	public void setSpec(final Spec spec) {
		this.spec = spec;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(final int limit) {
		this.limit = limit;
	}

	public int getFirstResult() {
		return firstResult;
	}

	public void setFirstResult(final int firstResult) {
		this.firstResult = firstResult;
	}

	public boolean isLock() {
		return lock;
	}

	public void setLock(final boolean lock) {
		this.lock = lock;
	}

	public List<String> getOrderParameters() {
		return orderParameters;
	}

}
